package com.example.shengyin.service;

import com.example.shengyin.dao.AttchMapper;
import com.example.shengyin.entity.Attach;
import com.example.shengyin.entity.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * AttachService业务层处理
 * 
 * @author gyy
 * @date 2023-07-29
 */
@Service
//@Transactional(readOnly = true, timeout = -1, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
@Cacheable(cacheNames = "attach",keyGenerator = "root")
public class AttachService
{

    @Autowired
    private AttchMapper dao;

    public Attach select(Long id)
    {
        return dao.select(id);
    }

    public List<Attach> list(Page page, String attachuri)
    {
        return dao.list((page.getPage()-1)*page.getLimit(),page.getLimit(),attachuri);
    }
    public int count(String attachuri)
    {
       return dao.count(attachuri);
    }
    @CacheEvict(allEntries = true,cacheNames = "attach")
    public int insert(Attach dAttach)
    {
        return dao.insert(dAttach);
    }
    @CacheEvict(allEntries = true,cacheNames = "attach")
    public int update(Attach dAttach)
    {
        return dao.update(dAttach);
    }
    @CacheEvict(allEntries = true,cacheNames = "attach")
    public int deleteByIds(String ids)
    {
        return dao.deleteByIds(ids);
    }
    @CacheEvict(allEntries = true,cacheNames = "attach")
    public int delete(int id)
    {
        return dao.delete(id);
    }
    public List<String> findCarouseel(){
        return dao.findCarouseel();
    }
    public List<Attach> page1(String carousel){
        return dao.page1(carousel);
    }
    public List<String> give(String carousel){
        return dao.give(carousel);
    }
    public Attach get(long id){
        return dao.getAll(id);
    }
}
